package homework.work6;

import java.util.Random;

public class Main {
    public static void main(String[] args) {
        Random random = new Random();
        // 生成[0, 999]范围内的随机数
        int randomNumber = random.nextInt(1000);
        // 将随机数字转换为三位字符串，不足三位前面补零
        String password = String.format("%03d", randomNumber);
        System.out.println("生成的密码是：" + password);
        int a=0,b=0,c=0;

        Logal:for(a=0;a<=9;a++){
            for(b=0;b<=9;b++){
                for(c=0;c<=9;c++){
                    String str="";
                    str=""+a+b+c;
                    System.out.print("str = " + str+"  ");
                    if(str.equals(password)){
                        System.out.println();
                        System.out.println("匹配成功");
                        break Logal;
                    }
                }
            }
        }
    }
}
